Skip to content

[5.x] Fix validation of date field nested in a replicator #11692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025

Conversation

liucf
Copy link
Contributor

@liucf liucf commented Apr 13, 2025

fix #11659

@liucf liucf changed the title fix: Remove validation logic from preProcessValidatable in Date field [5.x] Fix validation of date field nested in a replicator Apr 13, 2025
@liucf liucf marked this pull request as ready for review April 16, 2025 04:35
@jasonvarga
Copy link
Member

Thank you for the PR.

What you did simply prevented validation on nested date fields completely. We still need validation.

The issue was that the wrong field handle was being exposed in the validation error. There was no nesting. So really, even if you didn't have a conflicting field, the validation would fail but you'd see no error message at all.

I pushed an update so the validation would run using a generic field name, then re-throw with the appropriate handle path (e.g. replicator.3.date). This was simpler than trying to massage the value to match the expected structure.

I see that this extra validation is a bit awkward in general, but this'll do for now. 😄

@jasonvarga jasonvarga merged commit 1148a51 into statamic:5.x Apr 17, 2025
24 checks passed
@liucf
Copy link
Contributor Author

liucf commented Apr 18, 2025

Thank you for the PR.

What you did simply prevented validation on nested date fields completely. We still need validation.

The issue was that the wrong field handle was being exposed in the validation error. There was no nesting. So really, even if you didn't have a conflicting field, the validation would fail but you'd see no error message at all.

I pushed an update so the validation would run using a generic field name, then re-throw with the appropriate handle path (e.g. replicator.3.date). This was simpler than trying to massage the value to match the expected structure.

I see that this extra validation is a bit awkward in general, but this'll do for now. 😄

Thanks for merging it!

When I prevented validation, it only applied to nested fields — but they still exposed the correct field handles for validation. So from my perspective, skipping validation inside the nested fields seemed fine, since the parent level already takes care of validating them, as long as the handles are correctly mapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants